package com.neca.auction.pages;

import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry.annotations.Persist;

import com.neca.auction.dbb.DBBroker;
import com.neca.auction.model.Offer;
import com.neca.auction.model.Product;
import com.neca.auction.model.User;

public class ProductOffers {
	@Persist
	private Product product;
	@Persist
	private Offer offer;
	
	

	public Offer getOffer() {
		return offer;
	}

	public void setOffer(Offer offer) {
		this.offer = offer;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}
	
	public List<Offer> getAllOffers(){
		DBBroker dbbroker=DBBroker.getDbbroker();
		List<Offer> list= dbbroker.getAllOffers(product);
		if(list==null){
			return list;
		}else{
		List<Offer> l=new ArrayList<Offer>();
		for(int i=list.size()-1;i>-1;i--){
			l.add(list.get(i));
		}
		return l;
		}
		
	}
	
	public User getUser(){
		DBBroker dbbroker=DBBroker.getDbbroker();
		return dbbroker.getUserForOffer(offer);
	}

}
